package com.neo.design.chain;

import com.neo.design.chain.approve.ApproveRequest;
import com.neo.design.chain.payment.PaymentRequest;
import com.neo.web.beans.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChainController {

    @Resource
    private ChainContextManager chainContextManager;

    @PostMapping("/chain/approve")
    public Result<ChainResult> handleApprove(ApproveRequest request) {
        ChainResult chainResult = chainContextManager.handleRequest(request);
        return Result.ok(chainResult);
    }

    @PostMapping("/chain/pay")
    public Result<ChainResult> handlePay(PaymentRequest request) {
        ChainResult chainResult = chainContextManager.handleRequest(request);
        return Result.ok(chainResult);
    }
}
